﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NTiering.Models;

namespace NTiering.Mappers
{
    class SimpleMapper<Tfrom,Tto> : ISimpleMapper
        where Tfrom : class,IModel,new()
        where Tto : class,IModel,new()
    {
        private Func<Tfrom, Tto> _mapper;

        public SimpleMapper(Func<Tfrom, Tto> mapper)
        {
            _mapper = mapper;                  
        }

        
        public object Map(object from)
        {
            var to = new Tto() ;
            to = _mapper(from as Tfrom);
            return to;
        }
    }
}
